package com.zeedev.flyingsaucer.beers.activities.beerdialog;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.zeedev.flyingsaucer.beers.downloaders.BeerDownloader;

public class BeerDialogControllerImpl implements BeerDialogController {

    @Inject
    Provider<BeerDownloader> beerDownloaderProvider;

    private BeerDialogModel model;

    @Inject
    public BeerDialogControllerImpl(BeerDialogModel model) {
        this.model = model;
    }

    @Inject
    Provider<BeerDialog2> beerDialog2Provider;

    @Inject
    @Override
    public void init() {

        if (model.hasRecord() && model.isRecordComplete()) {
            //just display
//            beerDialog2Provider.get().bindView();/
            //There is no need it's bound to a cursor
            //TODO FIX
        } else if (model.hasRecord()) {
            //do load
            loadBeer();
        }

    }

    public void loadBeer() {
        beerDownloaderProvider.get().execute();
    }


}
